package com.happy.cat.project.system.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;

import java.util.List;
import java.util.Arrays;

import com.happy.cat.common.utils.StringUtils;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.happy.cat.framework.aspectj.lang.annotation.Log;
import com.happy.cat.framework.aspectj.lang.enums.BusinessType;
import com.happy.cat.project.system.domain.UserManitoVideoApply;
import com.happy.cat.project.system.service.IUserManitoVideoApplyService;
import com.happy.cat.framework.web.controller.BaseController;
import com.happy.cat.framework.web.domain.AjaxResult;
import com.happy.cat.common.utils.poi.ExcelUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import com.happy.cat.framework.web.page.TableDataInfo;

/**
 * 大神视频审核Controller
 *
 * @author verne
 * @date 2020-08-19
 */
@AllArgsConstructor
@RestController
@RequestMapping("/system/userManitoVideoApply" )
@Api("大神视频审核 API")
public class UserManitoVideoApplyController extends BaseController {

    private final IUserManitoVideoApplyService iUserManitoVideoApplyService;

    /**
     * 查询大神视频审核列表
     */
    @ApiOperation(value = "查询大神视频审核列表",notes = "查询大神视频审核列表",response = TableDataInfo.class)
    @PreAuthorize("@ss.hasPermi('system:userManitoVideoApply:list')")
    @GetMapping("/list")
    public TableDataInfo list(UserManitoVideoApply userManitoVideoApply)
    {
        startPage();
        LambdaQueryWrapper<UserManitoVideoApply> lqw = new LambdaQueryWrapper<UserManitoVideoApply>();
        if (userManitoVideoApply.getAccountId() != null){
            lqw.eq(UserManitoVideoApply::getAccountId ,userManitoVideoApply.getAccountId());
        }
        if (userManitoVideoApply.getManitoId() != null){
            lqw.eq(UserManitoVideoApply::getManitoId ,userManitoVideoApply.getManitoId());
        }
        if (StringUtils.isNotBlank(userManitoVideoApply.getVideoUrl())){
            lqw.eq(UserManitoVideoApply::getVideoUrl ,userManitoVideoApply.getVideoUrl());
        }
        if (userManitoVideoApply.getApplyStatus() != null){
            lqw.eq(UserManitoVideoApply::getApplyStatus ,userManitoVideoApply.getApplyStatus());
        }
        if (StringUtils.isNotBlank(userManitoVideoApply.getApplyText())){
            lqw.eq(UserManitoVideoApply::getApplyText ,userManitoVideoApply.getApplyText());
        }
        if (userManitoVideoApply.getApplyTime() != null){
            lqw.eq(UserManitoVideoApply::getApplyTime ,userManitoVideoApply.getApplyTime());
        }
        if (StringUtils.isNotBlank(userManitoVideoApply.getApplyBy())){
            lqw.eq(UserManitoVideoApply::getApplyBy ,userManitoVideoApply.getApplyBy());
        }
        List<UserManitoVideoApply> list = iUserManitoVideoApplyService.list(lqw);
        return getDataTable(list);
    }

    /**
     * 导出大神视频审核列表
     */
    @ApiOperation(value = "导出大神视频审核列表",notes = "导出大神视频审核列表",response = AjaxResult.class)
    @PreAuthorize("@ss.hasPermi('system:userManitoVideoApply:export')" )
    @Log(title = "大神视频审核" , businessType = BusinessType.EXPORT)
    @GetMapping("/export" )
    public AjaxResult export(UserManitoVideoApply userManitoVideoApply) {
        LambdaQueryWrapper<UserManitoVideoApply> lqw = new LambdaQueryWrapper<UserManitoVideoApply>(userManitoVideoApply);
        List<UserManitoVideoApply> list = iUserManitoVideoApplyService.list(lqw);
        ExcelUtil<UserManitoVideoApply> util = new ExcelUtil<UserManitoVideoApply>(UserManitoVideoApply. class);
        return util.exportExcel(list, "userManitoVideoApply" );
    }

    /**
     * 获取大神视频审核详细信息
     */
    @ApiOperation(value = "获取大神视频审核详细信息",notes = "获取大神视频审核详细信息",response = AjaxResult.class)
    @PreAuthorize("@ss.hasPermi('system:userManitoVideoApply:query')" )
    @GetMapping(value = "/{id}" )
    public AjaxResult getInfo(@PathVariable("id" ) Long id) {
        return AjaxResult.success(iUserManitoVideoApplyService.getById(id));
    }

    /**
     * 新增大神视频审核
     */
    @ApiOperation(value = "新增大神视频审核",notes = "新增大神视频审核",response = AjaxResult.class)
    @PreAuthorize("@ss.hasPermi('system:userManitoVideoApply:add')" )
    @Log(title = "大神视频审核" , businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UserManitoVideoApply userManitoVideoApply) {
        return toAjax(iUserManitoVideoApplyService.save(userManitoVideoApply) ? 1 : 0);
    }

    /**
     * 修改大神视频审核
     */
    @ApiOperation(value = "修改大神视频审核",notes = "修改大神视频审核",response = AjaxResult.class)
    @PreAuthorize("@ss.hasPermi('system:userManitoVideoApply:edit')" )
    @Log(title = "大神视频审核" , businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UserManitoVideoApply userManitoVideoApply) {
        return toAjax(iUserManitoVideoApplyService.updateById(userManitoVideoApply) ? 1 : 0);
    }

    /**
     * 删除大神视频审核
     */
    @ApiOperation(value = "删除大神视频审核",notes = "删除大神视频审核",response = AjaxResult.class)
    @PreAuthorize("@ss.hasPermi('system:userManitoVideoApply:remove')" )
    @Log(title = "大神视频审核" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}" )
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(iUserManitoVideoApplyService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
    }
}
